﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class operate_operateScore : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["operate"].ToString().Trim() == "del")
        {
            string student_id = Request["student_id"].ToString().Trim();
            string course_id = Request["course_id"].ToString().Trim();
            
            string sql = "delete tb_score "+ " where student_id ='" + student_id + "' and course_id ='" + course_id + "'";
            int k = SqlServer.ExecuteNonQuery(sql);
            if (k > 0)
            {
                Response.Write(k.ToString());

            }
            else
            {
                Response.Write("0");
            }
            Response.End();
        }
        if (Request["operate"].ToString().Trim() == "add")
        {
            string student_id = Request["student_id"].ToString().Trim();
            string course_id = Request["course_id"].ToString().Trim();
            string test_score = Request["test_score"].ToString().Trim();
            string sql ="insert into tb_score values('"+student_id+"','"+course_id+"',"+test_score+")";
            int k = SqlServer.ExecuteNonQuery(sql);
            if (k > 0)
            {
                Response.Write(k.ToString());

            }
            else
            {
                Response.Write("0");
            }
            Response.End();
        }
        if (Request["operate"].ToString().Trim() == "update")
        {
            string student_id = Request["student_id"].ToString().Trim();
            string course_id = Request["course_id"].ToString().Trim();
            string test_score = Request["test_score"].ToString().Trim();
            string sql = "update tb_score set test_score = " + test_score + " where student_id ='" + student_id + "' and course_id ='" + course_id + "'";
            int k = SqlServer.ExecuteNonQuery(sql);
            if (k > 0)
            {
                Response.Write(k.ToString());

            }
            else
            {
                Response.Write("0");
            }
            Response.End();
        }

    }
}